﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccessLayer;
using DataAccessLayer.DAL;

namespace BestBuy.UserControls
{
    public partial class PreviewProduct : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public Dictionary<string, int> SellerList
        {
            get
            {
                Dictionary<string, int> list = new Dictionary<string, int>();
                for (int i = 0; i < listboxSeller.Items.Count; i++)
                {
                    list.Add(listboxSeller.Items[i].Text, int.Parse(listboxSeller.Items[i].Value));
                }
                return list;
            }
            set
            {
                listboxSeller.DataSource = value;
                listboxSeller.DataTextField = "Key";
                listboxSeller.DataValueField = "Value";
                listboxSeller.Rows = value.Keys.Count + 1;
                listboxSeller.DataBind();
            }
        }
        public int ProductID
        {
            get
            {
                return int.Parse(hidProductID.Value);
            }
            set
            {
                DataAccessLayer.ProductCategory pro = ProductCategoryDAL.GetByID(value);
                if (pro != null)
                {
                    hidProductID.Value = pro.ID.ToString();
                    lbProduct.Text = pro.Name;
                }
            }
        }
        public bool AllowOthersSellerJoin
        {
            get
            {
                return bool.Parse(lbAllowJoin.Text);
            }
            set
            {
                lbAllowJoin.Text = value.ToString();
            }
        }
        public bool AuctionType
        {
            get
            {
                return bool.Parse(lbAuctionType.Text);
            }
            set
            {
                lbAuctionType.Text = value.ToString();
            }
        }
        public string Title
        {
            get
            {
                return lbTitle.Text;
            }
            set
            {
                lbTitle.Text = value;
            }
        }
        public string SubTitle
        {
            get
            {
                return lbSubTitle.Text;
            }
            set
            {
                lbSubTitle.Text = value;
            }
        }
        public string Description
        {
            get
            {
                return lbDescription.Text;
            }
            set
            {
                lbDescription.Text = value;
            }
        }
        public int Quantity
        {
            get
            {
                return int.Parse(lbQuantity.Text);
            }
            set
            {
                lbQuantity.Text = value.ToString();
            }
        }
        public int StartPrice
        {
            get
            {
                return int.Parse(lbStartPrice.Text);
            }
            set
            {
                lbStartPrice.Text = value.ToString();
            }
        }
        public int MaxPrice
        {
            get
            {
                return int.Parse(lbMaxPrice.Text);
            }
            set
            {
                lbMaxPrice.Text = value.ToString();
            }
        }
        public DateTime StartTime
        {
            get
            {
                return DateTime.Parse(lbStartTime.Text);
            }
            set
            {
                lbStartTime.Text = value.ToString();
            }
        }
        public DateTime EndTime
        {
            get
            {
                return DateTime.Parse(lbEndTime.Text);
            }
            set
            {
                lbEndTime.Text = value.ToString();
            }
        }
        public string ImageUrl
        {
            get
            {
                return imageProduct.ImageUrl;
            }
            set
            {
                imageProduct.ImageUrl = value;
            }
        }
        public Dictionary<string,int> Payment
        {
            get
            {
                Dictionary<string, int> list = new Dictionary<string, int>();
                for (int i = 0; i < listboxPayment.Items.Count; i++)
                {
                    list.Add(listboxPayment.Items[i].Text, int.Parse(listboxPayment.Items[i].Value));
                }
                return list;
            }
            set
            {
                listboxPayment.DataSource = value;
                listboxPayment.DataTextField = "Key";
                listboxPayment.DataValueField = "Value";
                listboxPayment.Rows = value.Keys.Count + 1;
                listboxPayment.DataBind();
            }
        }
        public string FreeShipping
        {
            get
            {
                return lbFreeShipping.Text;
            }
            set
            {
                lbFreeShipping.Text = value;
            }
        }
    }
}